package com.luna.serviceImpl;

import com.luna.beans.Note;
import com.luna.dao.NoteDao;
import com.luna.dao.PhaseDao;
import com.luna.service.NoteService;

import java.util.List;

public class NoteServiceImpl implements NoteService {
    @Override
    public List<Note> noteList(int book_id) {
        List<Note> list = null;
        NoteDao noteDao = new NoteDao();
        try {
            list = noteDao.selectAllNoteByBookId(book_id);
        } catch (Exception ignored) {}
        return list;
    }

    @Override
    public Note getNote(int note_id) {
        Note note = null;
        NoteDao noteDao = new NoteDao();
        try {
            note = noteDao.selectByNoteId(note_id);
        } catch (Exception ignored) {}
        return note;
    }

    @Override
    public boolean addNote(Note note) {
        NoteDao noteDao = new NoteDao();
        try {
            noteDao.insertNote(note);
        } catch (Exception _e) {
            return false;
        }
        return true;
    }

    @Override
    public boolean dropNote(int note_id) {
        NoteDao noteDao = new NoteDao();
        try {
            noteDao.dropNoteById(note_id);
        } catch (Exception _e) {
            return false;
        }
        return true;
    }

    @Override
    public boolean updateNote(int note_id, Note note) {
        NoteDao noteDao = new NoteDao();
        try {
            noteDao.updateNote(note_id, note);
        } catch (Exception _e) {
            return false;
        }
        return true;
    }
}
